<!--  -->
<template>
  <div>
    <i-form :formItem='formItem' :formFied='formFied' :btnMap="btnMap"></i-form>
    <el-button  @click="test">测试按钮</el-button>
    <el-tooltip :content="'Switch value: ' + value" placement="top">
      <el-switch v-model="value" active-color="#13ce66" inactive-color="#C0CCDA" active-value="100" inactive-value="0">
      </el-switch>
    </el-tooltip>
  </div>
</template>

<script>
import IForm from '../../components/common/form/i-form.vue';
import req from '@/api/org'
export default {
  data () {
    return {
      value: '100',
        formItem: [
            {
                label:'姓名', 
                prop: 'name',
                type:'input',
                required:true
            },
            {
                label:'活动', 
                prop: 'active',
                type:'select',
                option: [
                    {label: '区域一',value:'1'},
                    {label: '区域二',value:'2'}
                ]
            }
        ],
        formFied: {
            name:'',
            active:''
        },
        btnMap:[
          {
            text: '确定',
            type: 'primary',
            key: 'submit'
          },
          {
            text: '取消',
            type: 'primary',
            key: 'cancel',
            callback: () => {
              let a
              let b = []
              let c = {}
              if(a){
                console.log('a=',a)
                console.log(!a)
              }
              if(b){
                console.log('b=',b)
                console.log(!b)
              }
              if(c){
                console.log('c=',c)
                console.log(!c)
              }
              console.log('cancel-callback')
            }
          },
          {
            text: '重置',
            key: 'reset',
            type: 'info'
          }
        ]
    };
  },

  components: {IForm},

  computed: {},

  methods: {
    async test(){
      console.log('test')
      const res = await req('getOrgById',{
        id: 123456,
      })
      console.log('res=', res)
      const res1 = await req('getOrgByPage',{
        pageSize: 10,
        pageIndex: 1
      })
      console.log('res1=', res1)
    }
  }
}

</script>
<style lang='less' scoped>
</style>